﻿using ConfExpert.Forms.Base;
using ConfExpert.Utility;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Repository;
using DevExpress.XtraNavBar;
using DevExpress.XtraReports.UI;

using System.Linq;
using Extensions;
using DevTeamIT;

namespace ConfExpert.Forms.DockingControls
{
    public class SeasonBasedOperations : DockingControlBase
    { 
        public SeasonBasedOperations(NavBarControl navBar, GridLookUpEdit gleSeason)
        {
            NavigationBar = navBar;
            Lookup = gleSeason;

            NavigationBar.Groups.Clear();
            XForm x = new XForm();
            //RepositoryItemGridLookUpEdit riSeason = x.GetCustomGLE(RepositoryManager.dsi.CKBatch, "Notes", "CKBatchId");
            //Lookup.Properties.Assign(riSeason);
            Lookup.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            
            gleSeason.EditValueChanged += delegate { Refresh(Session.WhoAmI); };
            
            if (Session.gleSeason > 0)
                gleSeason.EditValue = Session.gleSeason;            
        }

        public void AddMenuItemCustomAction(NavBarGroup group, string caption)
        {
//            int ckBatchId = (int)Lookup.EditValue;
//            int brandId = RepositoryManager.dsi.CKBatch.FindByCKBatchId(ckBatchId).BrandId;

//            NavBarItem menu = new NavBarItem(caption);
//            menu.LinkClicked += delegate
//            {
//                /*
//                xrKesim xr = new xrKesim(brandId, "TR", ckBatchId);
//                xr.ShowPreview();
//*/
//                int RowCount = Session.DataManager.ExecuteScalar("InsGpToOrders", ckBatchId).ToInt();
//                if (RowCount > 0)
//                    XtraMessageBox.Show(RowCount.ToStr() + " satır aktarıldı.");
//                else
//                    XtraMessageBox.Show("Bu aktarım daha önce yapılmış.");
//            };
//            menu.SmallImage = Properties.Resources.btn1y;
//            group.ItemLinks.Add(menu);
//            group.Expanded = true;
        }
 

        public void Refresh(int WhoAmI)
        {
            NavBarGroup group;
            NavigationBar.Groups.Clear();
            int ckBatchId = (int)Lookup.EditValue;
            Session.gleSeason = ckBatchId; 

            group = AddGroup("Genel");
            //AddMenuItem(group, "Sezon Siparişi", typeof(CK), ckBatchId);
            //AddMenuItem(group, "Üretim Durumu", typeof(GpDurum), ckBatchId);
            //AddMenuItem(group, "Şu an Dikilebilecek Modeller", typeof(Dikilebilecek), ckBatchId);
            //AddMenuItem(group, "Kumaş İhtiyacı", typeof(Executions), ckBatchId, 0);
            //AddMenuItem(group, "Kumaş İhtiyacı - Kalan", typeof(KalanExecutionlar), ckBatchId);
            //AddMenuItem(group, "Kumaş İhtiyacı - Interaktif", typeof(KalanModeller), ckBatchId);
            //AddMenuItem(group, "Çıkış Partileri", typeof(CikisPartileri), ckBatchId);
            //AddMenuItem(group, "Kumaş Çıkışları", typeof(KumasVeUretim), ckBatchId);
            //AddMenuItem(group, "Kumaş ve Model", typeof(KumasVeModel), ckBatchId);
            //AddMenuItem(group, "Kumaş Durumu", typeof(SezonKumas), ckBatchId);
            //AddMenuItem(group, "Giden/Gelen Kumaş", typeof(DonmesiBeklenen), ckBatchId);
            //AddMenuItem(group, "Kumaş Fazlası", typeof(KumasFazlasi), ckBatchId);
            //AddMenuItem(group, "Beden Dağılım Trendi", typeof(BedenDagilimTrendi), ckBatchId);
            //AddMenuItem(group, "Numune Siparişi", typeof(NumuneSip), ckBatchId);
            //AddMenuItemCustomAction(group, "Sipariş modülüne aktar");
            //AddMenuItemCustomAction(group, "KF Önizleme");

            
        }
    }
}
